package Controllers;

import Backend.PrinterAgent;
import Models.LoginModel;
import Models.PrinterModel;
import PrinterSource.PrinterManager;
import PrinterSource.QueryHandler;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import org.apache.log4j.Logger;

public class PrinterSetControl extends HttpServlet {
    
    static Logger log = Logger.getLogger("SNMPLOG"); 
    
    public void doPost(HttpServletRequest request, 
                      HttpServletResponse response) 
                      throws IOException, ServletException {

        

        String name = request.getParameter("name");
        String colourenabled = request.getParameter("colourenabled");
        String defaultlang = request.getParameter("defaultlang");
        String printingcolour = request.getParameter("printingcolour");
        String papersize = request.getParameter("papersize");
        
        

        log.info(name + " SET");
        log.info(colourenabled + " SET");
        log.info(defaultlang + " SET");
        log.info(printingcolour + " SET");
        log.info(papersize + " SET");


        QueryHandler.set_Val(name, PrinterAgent.name, name);
        QueryHandler.set_Val(name, PrinterAgent.supports_colour, colourenabled);
        QueryHandler.set_Val(name, PrinterAgent.localisation, defaultlang);
        QueryHandler.set_Val(name, PrinterAgent.colour_printing, printingcolour);
        QueryHandler.set_Val(name, PrinterAgent.paper_size, name);

        //PrinterModel model = manager.getModel(Integer.parseInt(printernumber));


        RequestDispatcher view = request.getRequestDispatcher("Submitted.jsp");
        view.forward(request, response); 
    
    

    }
    
}
